package com.example.service.Impl;

import com.example.dao.CountryMapper;
import com.example.pojo.Country;
import com.example.pojo.CountryExample;
import com.example.service.CountryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ftl douyacai
 * @create 2017/12/1
 */
@Service
public class CountryServiceImpl implements CountryService {

    @Autowired
    private CountryMapper countryMapper;

    @Override
    public List<Country> findAll(CountryExample example) {
        List<Country> countryList = countryMapper.selectByExample(example);
        return countryList;
    }

    @Override
    public List<Country> findAll_enemy(CountryExample example) {
        return countryMapper.WithEnemyAttribute_selectByExample(null);
    }

    @Override
    public Country findOne(Integer id) {
        Country country = countryMapper.WithEnemyAttribute_selectByPrimaryKey(id);
        return country;
    }

    @Override
    public int insert(Country country) {
        return countryMapper.insertSelective(country);
    }

    @Override
    public Country selectByPrimaryKey(Integer id) {
        return countryMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKey(Country country) {
        return countryMapper.updateByPrimaryKey(country);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return countryMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<Country> WithEnemyAttributeSelectLike(String countryName) {
        return countryMapper.WithEnemyAttributeSelectLike(countryName);
    }

    @Override
    public List<Country> WithEnemyAttributeSelectLike1(String countryName, Integer enemyAttributeId) {
        return countryMapper.WithEnemyAttributeSelectLike2(countryName, enemyAttributeId);
    }


}
